package com.firefly.web.controller.admin.cms;

import com.firefly.web.controller.admin.ConsoleApiRestController;
import com.firefly.dao.dto.cms.LinkDto;
import com.firefly.dao.dto.cms.LinkSearchDto;
import com.firefly.dao.dto.CommonDto;
import com.firefly.dao.vo.CommonListVo;
import com.firefly.dao.vo.cms.LinkVo;
import com.firefly.service.command.cms.LinkCommand;
import com.firefly.service.query.cms.LinkQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * (Links)表控制层
 *
 * @author makejava
 * @since 2022-08-02 08:57:45
 */
@ConsoleApiRestController("/link")
public class LinkController {
    private final LinkQuery linkQuery;
    private final LinkCommand linkCommand;
    @Autowired
    public LinkController(LinkCommand linkCommand, LinkQuery linkQuery) {
        this.linkCommand = linkCommand;
        this.linkQuery = linkQuery;
    }
    @GetMapping("/list")
    public CommonListVo getAll(LinkSearchDto request) {
        return linkQuery.getList(request);
    }

    @GetMapping("/detail")
    public LinkVo getDetail(@Validated(CommonDto.showDetail.class) CommonDto request) {
        return linkQuery.getDetail(request);
    }

    @PostMapping("/create")
    public Boolean postCreate(@Validated(LinkDto.create.class) LinkDto request) {
        return linkCommand.create(request);
    }

    @PostMapping("/update")
    public Boolean postUpdate(@Validated(LinkDto.update.class) LinkDto request) {
        return linkCommand.update(request);
    }

    @PostMapping("/remove")
    public Boolean postRemove(@Validated(CommonDto.removeMultiple.class) CommonDto request) {
        return linkCommand.remove(request);
    }
}

